#pragma once
#include <iostream>
#include <pthread.h>
class Mutex
{
public:
    Mutex(pthread_mutex_t* pmtx) :pmtx_(pmtx)
    {}
    ~Mutex()
    {}
    void lock()
    {
        pthread_mutex_lock(pmtx_);
    }
    void unlock()
    {
        pthread_mutex_unlock(pmtx_);
    }
private:
    pthread_mutex_t* pmtx_;
};
//RAII风格的加锁方式
class lockGuard
{
public:
    lockGuard(pthread_mutex_t* pmtx) :mtx_(pmtx)
    {
        mtx_.lock();
    }
    ~lockGuard()
    {
        mtx_.unlock();
    }

private:
    Mutex mtx_;
};